package com.xxxx.spring.day06;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Component
public class E {

    @Lazy
    @Autowired
    private F1 f1;  // f1是一个延迟加载的自动注入的依赖,f1字段在容器启动时会保持为null

    @Autowired
    private F2 f2;

    @Autowired
    private ObjectFactory<F3> f3;

    @Autowired
    private ApplicationContext context;

    public F1 getF1(){
        return f1;
    }

    public F2 getF2(){
        return f2;
    }

    public F3 getF3(){
        return f3.getObject();
    }

    public F4 getF4(){
        return context.getBean(F4.class);
    }
}
